<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<meta property="wb:webmaster" content="0e6fa7689b62690b"/>
<head>
    <meta charset="utf-8">
    <title>博客后台管理-注册</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/css/register.css" media="all"/>
    <link href="/plugns/font-awesome/css/font-awesome.min.css" rel="stylesheet"/>
    <link rel="stylesheet" type="text/css" href="//at.alicdn.com/t/font_1041315_jae720uvik.css">
    <script src=http://tjs.sjs.sinajs.cn/open/api/js/wb.js?appkey=3209264839 type="text/javascript"
            charset="utf-8"></script>
</head>
<body>


<div class="layui-carousel" id="login_carousel">
    <div carousel-item id="imgH">
        <div class="img-item"><img src="/img/beijing.jpg"></div>
    </div>
</div>

<div class="register">
    <h1>注册！</h1>
    <form class="layui-form" action="/register">
        <div class="layui-form-item">
            <i class="iconfont icon-wulumuqishigongandashujuguanlipingtai-ico-"></i>
            <input class="layui-input" name="userName" placeholder="用户名" lay-verify="required" type="text"
                   autocomplete="off">
        </div>
        <div class="layui-form-item">
            <i class="iconfont icon-yonghu3"></i>
            <input class="layui-input" name="realName" placeholder="姓名" lay-verify="required" type="text"
                   autocomplete="off">
        </div>
        <div class="layui-form-item">
            <i class="iconfont icon-mima4"  ></i>
            <input  class="layui-input " id="firstPassword" name="password" placeholder="密码" lay-verify="required" type="password"
                   autocomplete="off">
        </div>
        <div class="layui-form-item">
            <i class="iconfont icon-mima4"  ></i>
            <input class="layui-input" id="secondPassword"  placeholder="确认密码" lay-verify="required" type="password"
                   autocomplete="off">
        </div>
        <div class="layui-form-item form_code">
            <i class="iconfont icon-class-o"></i>
            <div class="sex">
            <select name="sex" lay-verify="">
                <option value="">请选择性别</option>
                <option value="男">男</option>
                <option value="女">女</option>
            </select>
            </div>
        </div>
        <div class="layui-form-item">
            <i class="iconfont icon-youxiang" ></i>
            <input class="layui-input" name="email" id="email" placeholder="邮箱" lay-verify="required" type="email"
                   autocomplete="off">
        </div>
        <div class="layui-form-item ">
            <i class="iconfont icon-shouji4" ></i>
            <input class="layui-input" name="phone" id="mobile" placeholder="手机号" lay-verify="required" type="tel"
                   autocomplete="off">
        </div>
        <div class="layui-form-item form_code">
            <i class="iconfont icon-securityCode-b" ></i>
            <input class="layui-input" name="code" id="code" placeholder="验证码" lay-verify="required" type="text" autocomplete="off">
            <div class="code"><input class="layui-btn layui-btn-normal" type="button" id="btn" value="获取验证码" href="javascript:void(0);" onclick="settime(this)"/>
            </div>
        </div>
        <button class="layui-btn layui-btn-danger register_btn" lay-submit="" lay-filter="register">注册</button>
        <div class="layui-form-item login-other">
            <label style="color: orangered">第三方登录</label>
            <a href="qq/auth?status=1"><img src="/img/third/qq.png"></a>
            <a href="https://github.com/login/oauth/authorize?client_id=b89dffe6292d8735d34c&state=11&redirect_uri=http://moshang.work:8080/githubCallback; "><img
                    src="/img/third/github.jpg"></a>
            <a href="weibo/auth"><img src="/img/third/weibo.png"></a>
            <a href="/toLogin" style="color: red">请登录</a>
        </div>

    </form>
</div>
<script type="text/javascript" src="/layui/layui.js"></script>
</body>
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript" th:inline="none">
    layui.config({
        base: '/js/common/' //假设这是你存放拓展模块的根目录
    }).use(['layer','form','carousel','table','laypage','common'], function() {
        var layer = layui.layer,
        carousel = layui.carousel,
            form = layui.form,
        $ = layui.jquery;

        /**背景图片轮播*/
        carousel.render({
            elem: '#login_carousel',
            width: '100%' //设置容器宽度
            ,arrow: 'always' // 悬停显示箭头
            ,indicator: 'inside'
            ,height: 'auto'


        });
        //发送短信验证码
        $("#btn").on("click", function(){
            if($("#mobile").val()==''){
                layer.msg('请输入手机号',{icon: 5});
                return false;
            }
            var reg = /^1\d{10}$/;
            if(!reg.test($("#mobile").val())){
                layer.msg('请输入合法的手机号码',{icon: 5});
                return false;
            }
            $.ajax({
                type: 'get',
                url: 'sendSms?phone='+$("#mobile").val(),
                async: false,
                success: function (data) {
                    layer.msg(data.message,{icon: 6});
                },
                error:function(){
                   layer.msg(data.message,{icon: 2})
                }
            });
        })
        form.on('submit(register)', function(data) {
            if ($("#firstPassword").val()!=$("#secondPassword").val()){
                layer.msg('两次输入密码不一致！',{icon: 5});
            } else {
            var loading = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
            $.post(data.form.action, data.field, function(res) {
                layer.close(loading);
                if(res.success){
                    layer.msg('注册成功', {
                        icon: 1,
                        time: 5000 });
                    location.href=res.data.url;
                }else{
                    layer.msg(res.message);
                }
            });
            return false;
            }
        });

    });
    var countdown = 60;

    function settime(obj) {
        if (countdown == 0) {
            obj.removeAttribute("disabled");
            obj.value = "获取验证码";
            countdown = 60;

            return;
        } else {
            obj.setAttribute("disabled", true);
            obj.value = "重新发送(" + countdown + ")";

            countdown--;
        }
        setTimeout(function () {
                settime(obj)
            }
            , 1000)
    }

</script>
</html>